package com.ruoyi.pyo.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pyo.domain.PetYeahReceiverAddr;
import com.ruoyi.pyo.service.IPetYeahReceiverAddrService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 收件地址Controller
 * 
 * @author ruoyi
 * @date 2025-11-19
 */
@Api(tags = "用户地址")
@RestController
@RequestMapping("/pyo/addr")
public class PetYeahReceiverAddrController extends BaseController
{
    @Autowired
    private IPetYeahReceiverAddrService petYeahReceiverAddrService;

    /**
     * 查询收件地址列表
     */

    @PreAuthorize("@ss.hasPermi('pyo:addr:list')")
    @GetMapping("/list")
    @ApiOperation("查询收件地址列表")
    public TableDataInfo list(PetYeahReceiverAddr petYeahReceiverAddr)
    {
        startPage();
        List<PetYeahReceiverAddr> list = petYeahReceiverAddrService.selectPetYeahReceiverAddrList(petYeahReceiverAddr);
        return getDataTable(list);
    }

    /**
     * 导出收件地址列表
     */
    @ApiOperation("导出收件地址列表")
    @PreAuthorize("@ss.hasPermi('pyo:addr:export')")
    @Log(title = "收件地址", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PetYeahReceiverAddr petYeahReceiverAddr)
    {
        List<PetYeahReceiverAddr> list = petYeahReceiverAddrService.selectPetYeahReceiverAddrList(petYeahReceiverAddr);
        ExcelUtil<PetYeahReceiverAddr> util = new ExcelUtil<PetYeahReceiverAddr>(PetYeahReceiverAddr.class);
        util.exportExcel(response, list, "收件地址数据");
    }

    /**
     * 获取收件地址详细信息
     */
    @ApiOperation("获取收件地址详细信息")
    @PreAuthorize("@ss.hasPermi('pyo:addr:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(petYeahReceiverAddrService.selectPetYeahReceiverAddrById(id));
    }

    /**
     * 新增收件地址
     */
    @ApiOperation("新增收件地址")
    @PreAuthorize("@ss.hasPermi('pyo:addr:add')")
    @Log(title = "收件地址", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PetYeahReceiverAddr petYeahReceiverAddr)
    {
        return toAjax(petYeahReceiverAddrService.insertPetYeahReceiverAddr(petYeahReceiverAddr));
    }

    /**
     * 修改收件地址
     */
    @ApiOperation("修改收件地址")
    @PreAuthorize("@ss.hasPermi('pyo:addr:edit')")
    @Log(title = "收件地址", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PetYeahReceiverAddr petYeahReceiverAddr)
    {
        return toAjax(petYeahReceiverAddrService.updatePetYeahReceiverAddr(petYeahReceiverAddr));
    }

    /**
     * 删除收件地址
     */
    @ApiOperation("删除收件地址")
    @PreAuthorize("@ss.hasPermi('pyo:addr:remove')")
    @Log(title = "收件地址", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(petYeahReceiverAddrService.deletePetYeahReceiverAddrByIds(ids));
    }
}
